/* Cloudflare color palette and theme variables */
:root {
  --cf-orange: #f48120;
  --cf-dark-blue: #001835;
  --cf-blue: #0051c3;
  --cf-light-blue: #0098ec;

  /* Font stack */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

  /* Light mode */
  --background: #ffffff;
  --text: #001835;
  --secondary-text: #5c7291;
  --border: #e5e7eb;
  --input-bg: #f9fafb;
  --code-bg: #f3f4f6;
  --button-primary: var(--cf-blue);
  --button-primary-hover: var(--cf-dark-blue);
  --button-danger: #dc2626;
  --button-danger-hover: #991b1b;
}

/* Dark mode */
[data-theme="dark"] {
  --background: #001835;
  --text: #ffffff;
  --secondary-text: #94a3b8;
  --border: #1e293b;
  --input-bg: #0f172a;
  --code-bg: #1e293b;
  --button-primary: var(--cf-light-blue);
  --button-primary-hover: var(--cf-blue);
  --button-danger: #ef4444;
  --button-danger-hover: #dc2626;
}

/* Base styles */
body {
  background-color: var(--background);
  color: var(--text);
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Controls container */
.controls-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.75rem;
  z-index: 10;
  align-items: center;
}

/* Theme switch */
.theme-switch {
  position: relative;
  width: 3.5rem;
  height: 1.75rem;
  background: var(--input-bg);
  border-radius: 1rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  padding: 0.25rem;
}

.theme-switch::before {
  content: "🌙";
  position: absolute;
  left: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.theme-switch::after {
  content: "🌞";
  position: absolute;
  right: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.theme-switch[data-theme="dark"]::before {
  opacity: 1;
}

.theme-switch[data-theme="light"]::after {
  opacity: 1;
}

.theme-switch-handle {
  width: 1.25rem;
  height: 1.25rem;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.theme-switch[data-theme="light"] .theme-switch-handle {
  transform: translateX(1.75rem);
}

/* Clear history button */
.clear-history {
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: var(--input-bg);
  border: 1px solid var(--button-danger);
  color: var(--button-danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.clear-history:hover {
  color: white;
  background: var(--button-danger);
}

/* Chat container */
.chat-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  height: calc(100vh - 8rem); /* Leave space for top margin and input */
  margin: 4rem auto 0;
  padding: 0 1rem;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--secondary-text) var(--input-bg);
}

/* Webkit scrollbar styles */
.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-track {
  background: var(--input-bg);
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--secondary-text);
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: var(--text);
}

/* Messages wrapper to ensure proper spacing */
.messages-wrapper {
  flex: 1;
  padding-bottom: 5rem; /* Space for input */
}

/* Message styles */
.message {
  white-space: pre-wrap;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
}

.message strong {
  color: var(--cf-orange);
  font-weight: 600;
  font-family: var(--font-sans);
}

.message-content {
  margin-top: 0.5rem;
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

/* Tool invocation styles */
.dynamic-info {
  font-family: var(--font-mono);
  background-color: var(--code-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: var(--cf-orange);
}

.tool-invocation {
  color: var(--secondary-text);
  background: var(--input-bg);
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  margin-top: 0.5rem;
  font-family: var(--font-sans);
}

/* Button styles */
.button-container {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
}

.button-approve,
.button-reject {
  padding: 0.5rem 1rem;
  font-weight: 600;
  color: white;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 0.875rem;
  font-family: var(--font-sans);
}

.button-approve {
  background-color: var(--button-primary);
}

.button-approve:hover {
  background-color: var(--button-primary-hover);
}

.button-reject {
  background-color: var(--button-danger);
}

.button-reject:hover {
  background-color: var(--button-danger-hover);
}

/* Input styles */
.chat-input {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 26rem;
  padding: 0.75rem 1rem;
  margin-bottom: 2rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.chat-input:focus {
  outline: none;
  border-color: var(--cf-light-blue);
  box-shadow: 0 0 0 3px rgba(0, 152, 236, 0.1);
}

.chat-input:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  background: var(--code-bg);
}
